﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using WBGDal;
using WBGModel;

namespace uVirtualWeb
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                CarregaLista();
            }
        }

        private void CarregaLista()
        {
            short conf = new DalConfig().Carregar().webQtdNoticias;
            IEnumerable<ModelWebNews> lst;
            if (conf > 0)
                lst = new DalWebNews().Listar().OrderByDescending(x => x.creationDate).Take(conf);
            else
                lst = new DalWebNews().Listar().OrderByDescending(x => x.creationDate);
            lstNews.DataSource = lst;
            lstNews.DataBind();
            upNews.Update();
        }
    }
}
